package com.xbongbong.saas.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.saas.enums.business.ContractEnum;
import com.xbongbong.saas.enums.business.CustomerCommunicateEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/27 18:29
 * @since v1.0
 */
@Getter
public enum WorkReportTargetThroughFieldEnum {
    CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(),Arrays.asList(CustomerManagementEnum.NAME.getAttr(),CustomerManagementEnum.TYPE.getAttr(),CustomerManagementEnum.LAST_CONNECT_TIME.getAttr(),CustomerManagementEnum.ADD_TIME.getAttr(),CustomerManagementEnum.CREATOR_ID.getAttr())),
    CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(),Arrays.asList(ContractEnum.NAME.getAttr(),ContractEnum.CONTRACT_NO.getAttr(),ContractEnum.AMOUNT.getAttr(),ContractEnum.LINK_CUSTOMER.getAttr(),ContractEnum.SIGN_TIME.getAttr())),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(),Arrays.asList(CustomerCommunicateEnum.CUSTOMER_NAME.getAttr(),CustomerCommunicateEnum.COMMUNICATE_BUSINESS.getAttr(),CustomerCommunicateEnum.TYPE.getAttr(),CustomerCommunicateEnum.ADD_TIME.getAttr(),CustomerCommunicateEnum.CREATOR_ID.getAttr())),
    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(),Arrays.asList()),
    OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),Arrays.asList(SalesOpportunityEnum.NAME.getAttr(),SalesOpportunityEnum.SERIAL_NO.getAttr(),SalesOpportunityEnum.CUSTOMER_NAME.getAttr(),SalesOpportunityEnum.ESTIMATE_AMOUNT.getAttr(),SalesOpportunityEnum.UNIT.getAttr(),SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr(),SalesOpportunityEnum.ADD_TIME.getAttr(),SalesOpportunityEnum.CREATOR_ID.getAttr())),
    ;
    private Integer businessType;
    private List<String> fieldList;

    WorkReportTargetThroughFieldEnum(Integer businessType, List<String> fieldList) {
        this.businessType = businessType;
        this.fieldList = fieldList;
    }
    public static List<String> getByBusinessType(Integer businessType) {
        for (WorkReportTargetThroughFieldEnum workReportTargetThroughFieldEnum : values()) {
            if (Objects.equals(workReportTargetThroughFieldEnum.getBusinessType(), businessType)) {
                return workReportTargetThroughFieldEnum.getFieldList();
            }
        }
        return new ArrayList<>();
    }
}
